home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / mixisam / istest2.c < prev    next >
C/C++ Source or Header  |  1992-07-19  |  2KB  |  62 lines

  1. /*  ISAM test program #2.  This program will serve to test the ISAM library  */
  2. /*  functions we have created, and, when successfully executed, should serve */
  3. /*  as a model for any future programs incorporating the ISAM libraries.     */
  4. #include "rarisam.c"
  5.  
  6.  
  7. FILE *print_file;
  8. Db_Obj *phone_database;
  9. Index_Obj *phone_index;
  10. char name[21] = " ";
  11. char phone_area[4] = " ";
  12. char phone_exchange[4] = " ";
  13. char phone_body[5] = " ";
  14. char *phone_format[] = {
  15.     "name",
  16.     "area code",
  17.     "exchange",
  18.     "body number",
  19.     NULL
  20. };
  21.  
  22. char *phone_index_format[] = {
  23.     "name",
  24.     NULL
  25. };
  26.  
  27.  
  28.  
  29. main()
  30. {
  31.     print_file = fopen("lpt1", "a");
  32.     isam_open(&phone_database, "phone", &phone_index, "name");
  33.     isam_search(phone_database, phone_index, "Dean");
  34.     move_data_to_fields();
  35.     fprintf(print_file, "Name: %s.  Phone: (%s) %s-%s.\n", name, phone_area,
  36.         phone_exchange, phone_body);
  37.     isam_next(phone_database, phone_index);
  38.     move_data_to_fields();
  39.     fprintf(print_file, "Name: %s.  Phone: (%s) %s-%s.\n", name, phone_area,
  40.         phone_exchange, phone_body);
  41.     isam_prev(phone_database, phone_index);
  42.     move_data_to_fields();
  43.     fprintf(print_file, "Name: %s.  Phone: (%s) %s-%s.\n", name, phone_area,
  44.         phone_exchange, phone_body);
  45.     isam_prev(phone_database, phone_index);
  46.     move_data_to_fields();
  47.     fprintf(print_file, "Name: %s.  Phone: (%s) %s-%s.\n", name, phone_area,
  48.         phone_exchange, phone_body);
  49.     fprintf(print_file, "END OF RUN\n");
  50.     fclose(print_file);
  51.     isam_close(phone_database);
  52. }
  53.  
  54. move_data_to_fields()
  55. {
  56.     strcpy(name, *(fields + 0));
  57.     strcpy(phone_area, *(fields + 1));
  58.     strcpy(phone_exchange, *(fields + 2));
  59.     strcpy(phone_body, *(fields + 3));
  60. }
  61.  
  62.